<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <div>demo - div</div>
    <div>demo - div</div>
    <div>demo - div</div>
    <div>demo - div</div>
    <div>demo - div</div>

    <script>
        //函数自调用
        (function(window, undefined) {
            //工厂函数 内部 new init
            var jQuery = function(selector) {
                return new jQuery.fn.init(selector); //为了可以省去new

            }
            jQuery.fn = jQuery.prototype = {
                constructor: jQuery,
                init: function(selector) {
                    var elements = document.querySelectorAll('div');
                    [].push.apply(this, elements);
                },
                css: function() {
                    console.log('css is OK');
                },
                html: function() {
                    console.log('html is OK');
                }
            }
            jQuery.fn.init.prototype = jQuery.fn;
            window.jQuery = window.$ = jQuery;
        })(window)
        var divs = $('div');
        console.log(divs);
        divs.html();
        divs.css();
    </script>
</body>

</html>